#ifndef SENSORMANAGER_H
#define SENSORMANAGER_H

// Qt includes
#include <QObject>
#include <QTimer>

// Qt Mobility includes
#include <QSensor>

// Qt Mobility namespace
QTM_USE_NAMESPACE

// Forward declarations
class ReadingValueModel;
class SensorModel;


class SensorManager : public QObject
{
    Q_OBJECT
    Q_PROPERTY(QString sensorType READ sensorType WRITE setSensorType NOTIFY sensorTypeChanged)
    Q_PROPERTY(int sensorDataRate READ sensorDataRate WRITE setSensorDataRate NOTIFY sensorDataRateChanged)

public:
    explicit SensorManager(QObject *parent = 0);
    virtual ~SensorManager();

public:
    Q_INVOKABLE QSensor *currentSensor() const;
    SensorModel *sensorModel() const;
    ReadingValueModel *readingValueModel() const;
    QString sensorType() const;
    int sensorDataRate() const;

public slots:
    bool setSensorType(const QString &type);
    bool setSensorDataRate(int dataRate);

private slots:
    void populateSensorModel();
    void setSensorDataRate();

signals:
    void sensorTypeChanged(const QString &type);
    void sensorDataRateChanged(int dataRate);

private: // Data
    QSensor *m_currentSensor; // Owned
    SensorModel *m_sensorModel; // Owned
    ReadingValueModel *m_readingValueModel; // Owned
    QTimer m_timer;
    int m_dataRateToSet;
};

#endif // SENSORMANAGER_H
